<%@ page import="java.util.List" %>
<%@ page import="pojo.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<html>
<head>
    <title>index</title>
</head>
<body>
<a href="<%=request.getContextPath()%>/">返回首页</a>
<a href="<%=request.getContextPath()%>/add.jsp">新增User</a><br /><br />
<table border="1" width="60%" cellpadding="10" cellspacing="0">
    <thead>
        <th>ID</th>
        <th>用户名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>电话</th>
        <th>操作</th>
    </thead>
    <tbody>
    <%
        List<User> userList = (List<User>)request.getAttribute("userList");
        if(userList.size() > 0){
            for (int i = 0 ; i < userList.size() ; i++){
                User user = userList.get(i);
    %>
                <tr>
                    <td><%=user.getId()%></td>
                    <td><%=user.getUsername()%></td>
                    <td><%=user.getAge()%></td>
                    <td><%=user.getGender()%></td>
                    <td><%=user.getPhone()%></td>
                    <td><a href="<%=request.getContextPath()%>/delete.action?id=<%=user.getId()%>">删除</a></td>
                </tr>
    <%
            }
        }
    %>
    </tbody>
</table>
</body>
</html>
